package com.pengtu.entity.quality;

import java.util.Comparator;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.pengtu.entity.IdEntity;
import com.pengtu.entity.app.Attachment;

@Entity
@Table(name = "T_Q_MEETING")
public class Meeting extends IdEntity {

	/**
	 * serialVersionUID:TODO
	 * 
	 * @since 1.0.0
	 */

	private static final long serialVersionUID = 1L;

	private String pid;
	private String partner;
	private Date partDate;
	private String type;
	private String issue;
	private String content;
	private String matter;
	private String dealResult;
	private String issuefile;
	private String remark;
	private Set<Attachment> attachmentSet = new TreeSet<Attachment>(new Comparator<Attachment>() {
		@Override
		public int compare(Attachment attFirst, Attachment attSecond) {
			// TODO Auto-generated method stub
			return attFirst.getCreateDate().compareTo(attSecond.getCreateDate());
		}
	});                        //会议文件
	

	@Column(name="PID")
	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}
	
	@Column(name="PARTNER")
	public String getPartner() {
		return partner;
	}

	public void setPartner(String partner) {
		this.partner = partner;
	}

	@Column(name="PARTDATE")
	public Date getPartDate() {
		return partDate;
	}

	public void setPartDate(Date partDate) {
		this.partDate = partDate;
	}
	
	@Column(name="TYPE")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Column(name="ISSUE")
	public String getIssue() {
		return issue;
	}

	public void setIssue(String issue) {
		this.issue = issue;
	}
	
	@Column(name="CONTENT")
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Column(name="MATTER")
	public String getMatter() {
		return matter;
	}

	public void setMatter(String matter) {
		this.matter = matter;
	}

	@Column(name="DEALRESULT")
	public String getDealResult() {
		return dealResult;
	}

	public void setDealResult(String dealresult) {
		this.dealResult = dealresult;
	}

	@Column(name="ISSUEFILE")
	public String getIssuefile() {
		return issuefile;
	}

	public void setIssuefile(String issuefile) {
		this.issuefile = issuefile;
	}

	@Column(name="REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@JoinColumn(name = "TABLEID")
	public Set<Attachment> getAttachmentSet() {
		return attachmentSet;
	}
	
	public void setAttachmentSet(Set<Attachment> attachmentSet) {
		
		this.attachmentSet = attachmentSet;
	}
	
	@Transient
	public Attachment getAttachment(){
		if(attachmentSet.iterator().hasNext())
		return attachmentSet.iterator().next();
		return new Attachment();
	}

	public void setAttachment(Attachment attachment){
		attachmentSet.clear();
		attachmentSet.add(attachment);
	}

	public Meeting() {
		super();
	}

}
